// fetchData.ts
import api from "@/api"
import { UserManageItm } from "@/api/modules/authorityMenu";
import { ClassifiesItem } from "@/api/modules/goodsClassifies";
import { ref } from "vue";
export function useFetchData() {
    const classifyData = ref<ClassifiesItem[]>([]);
    // 所有权限菜单
    const allUserMenu=ref<UserManageItm[]>([])

    // 获取所有商品分类数据
    const getClassifyDataAsync = async () => {
        const res = await api.goodsClassifies.search();
        if (res.code === 200) {
            classifyData.value = res.data.rows;
        }
    }

    // 获取所有菜单数据
    const getPermissionDataAsync=async()=>{
        const res = await api.authorityMenu.search();
        if (res.code === 200) {
            allUserMenu.value = res.data.rows;
        }
    }
    return {
        getClassifyDataAsync,
        classifyData,
        getPermissionDataAsync,
        allUserMenu
    }
}